
<?php
$ten = $_REQUEST["ten"];
include("config/config.php");
$lenh = "select malaptop,tenlaptop,hinh from laptop where tenlaptop like'%$ten%'";
$kq = mysql_query($lenh);
$n = mysql_num_rows($kq);
if($n > 0)
{
$tb = "Tìm thấy ".$n." sản phẩm";	
}
else
{
$tb = "Không tìm thấy sản phẩm nào !";
}

$sodong = 5;
$sotrang = ceil($n/$sodong);
if(!$_GET["p"])
$p = 1;
else
$p = $_GET["p"];
$x = ($p-1)*$sodong;
$lenh1 = "select malaptop,tenlaptop,hinh,concat(format(dongia,0),' VNĐ')as dongia,concat(soluong,' Cái')as soluong from laptop where tenlaptop like'%$ten%' limit $x,$sodong";
$kq1 = mysql_query($lenh1);
?>
<link href="../style/cs1.css" rel="stylesheet" type="text/css">

  <table width="900" border="1" align="center" cellpadding="0" cellspacing="0" class="table_timkiem">
    <tr>
      <td height="30" align="center" class="dangkythanhvien" colspan="2">Tìm Kiếm Sản Phẩm</td>
    </tr>
 
      <td colspan="2">
      <?php  if(isset($_REQUEST["ten"])) echo $tb;    ?>
      </td>
    </tr>
     <?php
	  if(isset($_REQUEST["ten"]))
	  {
		  
	  while($row = mysql_fetch_array($kq1))
	  {
		  $nd = str_replace($ten,'<span style="background-color:#FF0; color:#F00">'.$ten.'</span>',$row[1]);
		  ?>
    <tr>
    <td>
    <img src="laptop/<?php  echo $row[2];     ?>" width="120" height="100" alt="Bán laptop online" title="Bán laptop online"/><br/></td>
    <td>
      
     
          <font color="#000000" style="padding-left:10px;">
		  <a href="index.php?idlaptop=<?php  echo $row[0];  ?>"><?php  echo $nd;     ?></a><br/>
          <font style="padding-left:10px;">Đơn giá:</font><?php echo $row[3];       ?><br/>
          <!--<font style="padding-left:10px;">Số lượng:</font><?php echo $row[4];       ?><br/>-->
          <div class="xemchitiet"><a href="index.php?idlaptop=<?php echo $row[0];   ?>">Xem chi tiêt >></a>
    <a href="index.php?act=gh&Malaptop=<?php  echo $row[6];    ?>"><br/>
    <img src="image/dathang.gif" width="103" height="30" border="0" /></a>
    </div>
          </font><br/>
          
          
        <?php
		  
	  }
	  }
	  
	  ?>
      </td>
    </tr>
  </table>
  <p align="center" style="clear:both">
<?php
 if(isset($_REQUEST["ten"]))
	  {
for($i = 1; $i <= $sotrang; $i++)
{
	if($i==$p)
	{
		echo $i;		
	}
	else
	{
		?>
		<a href="index.php?act=timkiem&ten=<?php echo $ten;  ?>&p=<?php echo $i;   ?>"><?php echo $i;   ?></a>
        <?php
	}
}
	  }
?>
</p>

